#pragma once
#include <iostream>
#include <functional>
class Task
{
    using func_t = std::function<int(int, int, char)>;

public:
    Task() {}
    Task(int x, int y, char op, func_t func)
        : _x(x), _y(y), _op(op), _callBack(func)
    {
    }
    std::string operator()()// 消费者调用
    {
        int result = _callBack(_x, _y, _op);
        char buffer[1024];
        snprintf(buffer, sizeof(buffer), "%d %c %d = %d", _x, _op, _y, result);
        return buffer;
    }
    std::string toString()// 生产者调用
    {
        char buffer[1024];
        snprintf(buffer, sizeof(buffer), "%d %c %d = ?", _x, _op, _y);
        return buffer;
    }

private:
    int _x, _y;
    char _op;
    func_t _callBack; // 回调函数
};